﻿#include "testdialog.h"
#include "ui_testdialog.h"

TestDialog::TestDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::TestDialog)
{
    ui->setupUi(this);

    QStringList header;
    header<<"账号"<<"密码"<<"备注";
    ui->tableWidget->setHorizontalHeaderLabels(header);

    ui->tableWidget->setItem(0,0,new QTableWidgetItem(QString("admin")));
    ui->tableWidget->setItem(1,0,new QTableWidgetItem("panpan"));
    ui->tableWidget->setItem(2,0,new QTableWidgetItem("xiaoming"));

    ui->tableWidget->setItem(0,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/add.png"),"管理员"));
    ui->tableWidget->setItem(1,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/accept.png"),"用户a"));
    ui->tableWidget->setItem(2,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/book.png"),"用户b"));

    ui->tableWidget->setItem(0,2,new QTableWidgetItem(QIcon(":/new/prefix1/res/book.png"),"备注"));
    //ui->tableWidget->show();
    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableWidget->setColumnHidden(2,true);
}

TestDialog::~TestDialog()
{
    delete ui;
}

void TestDialog::on_pushButton_clicked()
{
    ui->tableWidget->clear();
}

void TestDialog::on_pushButton_2_clicked()
{
    QStringList header;
    header<<"账号"<<"密码"<<"备注";
    ui->tableWidget->setHorizontalHeaderLabels(header);

    ui->tableWidget->setItem(0,0,new QTableWidgetItem("admin"));
    ui->tableWidget->setItem(1,0,new QTableWidgetItem("panpan"));
    ui->tableWidget->setItem(2,0,new QTableWidgetItem("xiaoming"));

    ui->tableWidget->setItem(0,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/add.png"),"管理员"));
    ui->tableWidget->setItem(1,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/accept.png"),"用户a"));
    ui->tableWidget->setItem(2,1,
        new QTableWidgetItem(QIcon(":/new/prefix1/res/book.png"),"用户b"));

    ui->tableWidget->setItem(0,2,new QTableWidgetItem(QIcon(":/new/prefix1/res/book.png"),"备注"));
}
